Repository navigation
fix(api): report a stalled indexer when there is no finality data - #133
Merged
Merged
Conversation
stale on /ready, /coverage and _coverage came only from the safe-head comparison and answered false whenever finality data was absent, so a deployment without FINALITY_ENABLED looked healthy however far behind it fell. graphql.ens.dev sat ~40h behind Sepolia reporting stale:false. COVERAGE_STALE_AFTER_SECONDS (opt-in, default 0) adds a fallback when there is no safe position: stale when any indexed protocol has gone longer than the threshold without committing a batch, or when nothing has synced at all. Finality data still decides on its own when present. - One live protocol no longer masks a dead one: the fold is an OR over protocols with a sync_state row, not max(last_synced_at). - Never-synced reads stale once armed instead of healthy forever. - A timestamp ahead of the API clock reads as age 0 and warns once per process; the subtraction saturates on hostile DB values. - Off by default: healthy bulk-sync batches have taken 10-44 min, and --backfill and END_BLOCK-pinned deployments never advance the head. - off/false/no parse as disabled; any other non-integer is logged instead of silently becoming a threshold. - /ready, /coverage, _coverage and /metrics share coverageStale. The existing ensv2_indexing_stale gauge keeps its _finality.isStale meaning; the new ensv2_coverage_stale gauge mirrors /coverage.
The code default stays off. The deployments we run opt in at 3600s, above the longest healthy batch on record, overridable per host.
v1rtl
force-pushed
the
fix/coverage-stale-without-finality
branch
from
September 29, 2026 13:56
77c4327 to
0202bc6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
staleon/ready,/coverageand_coveragecame only from the safe-head comparison, and it answeredfalsewhenever finality data was absent. A deployment without finality therefore looked healthy however far behind it fell.graphql.ens.devhas no finality data (_finality.safeisnull) and sat ~40h behind Sepolia while reportingstale: false.Change
COVERAGE_STALE_AFTER_SECONDSadds a fallback for when there is no safe position. It is opt-in: the code default is 0 (off), and the shipped compose files set 3600.With the fallback on, a deployment is stale when either:
When finality data exists, it still decides on its own.
Every surface now calls one shared function,
api/common.coverageStale:/ready,/coverage,_coverage, and a new/metricsgauge.What changed since the first review
stale:falseforever; with the fallback on it now reads stale.max(v1, v2); it now flags any protocol with a sync_state row that has gone past the threshold. A protocol this deployment doesn't index has no row and is ignored, so the V2-onlygraphql.ens.dev(V1lastSyncedAt: null) is unaffected.--backfillwrites nolast_synced_at, and END_BLOCK-pinned boxes stop writing, so a 900s default flagged healthy deployments. Operators now opt in:${COVERAGE_STALE_AFTER_SECONDS:-3600}, above the worst recorded batch..env.examplesays to set 0 during a backfill or on a pinned box.last_synced_atahead of the API clock reads as age 0 and logs a warning once per process. The subtraction saturates on hostile DB values.off/false/nodisable the fallback. Any other non-integer (e.g.1h) is logged instead of silently becoming a threshold; previouslyoffsilently meant 900./metrics.ensv2_indexing_stalekeeps its_finality.isStalemeaning (1 whenever there is no safe data), so existing alerts don't change.ensv2_coverage_stalemirrors/coverage.writeFinalityGauges.handleCoverageis fixed, and the schema descriptions describe opt-in behaviour.Tests
isStale/coverageStalecover:_coverage.stalethrough the real handler: off, never synced, fresh, one dead protocol, and finality overriding both waysOut of scope (follow-up)
With finality enabled, a dead indexer still reports
stale:false, because finality freezes along with it. The same gap exists in_finality.isStale.zig build test-all: 89/89 steps, 1493/1493 tests (zig 0.16.0). The Postgres lanes were not run locally; CI covers them. The postgres driver test literal carries bothrpc_rate_limit_per_secondandcoverage_stale_after_seconds.